/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package util.time;

/**
 *
 * @author Rdelacruz
 */
public class Cronometro {
    long tiempoInicial;
    
    //MEDIR EL TIEMPO
    //http://stackoverflow.com/questions/1770010/how-do-i-measure-time-elapsed-in-java
    //NO USAR: System.currentTimeMillis(), porque no es exacto
    public static void main(String args[]) {
        long tiempo1 = System.nanoTime();
        
        long tiempo2 = System.nanoTime();
        
        long dif = tiempo2 - tiempo1;
        System.out.println("dif"+dif);
    }
    
    public void iniciar() {
        tiempoInicial = System.nanoTime();
    }
    
    public long medirEnSegundos() {
        return (System.nanoTime() - tiempoInicial)/1000000000;
    }
    
    public long medirEnMiliSegundos() {
        return (System.nanoTime() - tiempoInicial)/1000000;
    }
    
    public long medirEnNanoSegundos() {
        return System.nanoTime() - tiempoInicial;
    }
}
